package com.campus.campusdelivery.constant;

public enum OrderStatus {
    PENDING("PENDING", "待支付"),
    PAID("PAID", "已支付"),
    CONFIRMED("CONFIRMED", "商家已确认"),
    PREPARING("PREPARING", "制作中"),
    READY("READY", "待配送"),
    DELIVERING("DELIVERING", "配送中"),
    DELIVERED("DELIVERED", "已送达"),
    COMPLETED("COMPLETED", "已完成"),
    CANCELLED("CANCELLED", "已取消"),
    REFUNDED("REFUNDED", "已退款");

    private final String code;
    private final String description;

    OrderStatus(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static OrderStatus fromCode(String code) {
        for (OrderStatus status : values()) {
            if (status.code.equals(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("Unknown order status code: " + code);
    }
}
